/*
 * @Author: your name
 * @Date: 2020-08-16 09:34:24
 * @LastEditTime: 2020-08-16 09:52:21
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \demo\day02\demo01\main.go
 */
package main

import "fmt"

type person struct {
	Name string
	Age  int
	city string
}

func (p person) eat() {
	fmt.Println("正在吃饭")
}

func main() {
	// ----------------------------------------
	var p person
	p.Name = "张三"
	p.Age = 12
	p.city = "小小"
	fmt.Printf("%v, %#v \n", p, p)
	// ----------------------------------------
	p1 := &person{
		Name: "王五",
		Age:  12,
		city: "地球",
	}
	fmt.Println(p1)
	// ----------------------------------------
	p2 := &person{}
	p2.Name = "假按揭啊"
	p2.Age = 12
	p2.city = "Dddd"
	fmt.Println(p2)
	// ----------------------------------------
	// 匿名结构体
	var user struct {
		Name string
		Age  int
	}
	user.Name = "哈哈"
	user.Age = 33
	fmt.Println(user)
	// ----------------------------------------
	// 指针结构体 类似上面的&person{}
	var p3 = new(person)
	fmt.Println(p3)
	p3.eat()
	// ----------------------------------------

}
